﻿// ....................................................................................................................
//	Author: Copyright (C) 2012 Ing. Marek Hubal
//	Email: hubal@acasoftware.org
// ....................................................................................................................

using System;

namespace core
{
    /// <summary>Trieda IAttributeChangeDataObject</summary>
    public class IAttributeChangeDataObject
    {
        public int Attr_Archive; // Sposob nastavenia atributov
        public int Attr_Hidden;
        public int Attr_System;
        public int Attr_ReadOnly;
        public bool Change_DCreate; // Priznaky nastavenia datumov
        public bool Change_DModify;
        public bool Change_DLastAccess;
        public DateTime Change_DCreate_Value; // Nove hodnoty datumov
        public DateTime Change_DModify_Value;
        public DateTime Change_DLastAccess_Value;
        public bool ApplyToSubfolders; // Priznak nastavenia aj podpriecinkov
        
        public uint UnixAttributes; // Unixovske atributy
        public bool UseUnixAttributes; // Priznak pouzitia unixovsky atributov

        /// <summary>Property: AnyChange</summary>
        public bool AnyChange
        {
            get
            {
                if (UseUnixAttributes) return true;
                if (Attr_Archive != ICore.TS_NONE) return true;
                if (Attr_Hidden != ICore.TS_NONE) return true;
                if (Attr_System != ICore.TS_NONE) return true;
                if (Attr_ReadOnly != ICore.TS_NONE) return true;
                if (Change_DCreate) return true;
                if (Change_DModify) return true;
                if (Change_DLastAccess) return true;
                return false;
            }
        }

        /// <summary>Konstruktor</summary>
        public IAttributeChangeDataObject()
        {
            Init(); // Inicializujem
        }

        /// <summary>Inicializacia</summary>
        public void Init()
        {
            Attr_Archive = ICore.TS_NONE;
            Attr_Hidden = ICore.TS_NONE;
            Attr_System = ICore.TS_NONE;
            Attr_ReadOnly = ICore.TS_NONE;
            Change_DCreate = false; Change_DLastAccess = false; Change_DModify = false;
            Change_DCreate_Value = Change_DLastAccess_Value = Change_DModify_Value = DateTime.Now;
            ApplyToSubfolders = false;
            UnixAttributes = 0;
        }
        /// <summary>Skopirovanie obsahu objektu</summary>
        /// <param name="pValue">objekt na skopirovania</param>
        public void Assign(IAttributeChangeDataObject pValue)
        {
            Attr_Archive = pValue.Attr_Archive;
            Attr_Hidden = pValue.Attr_Hidden;
            Attr_System = pValue.Attr_System;
            Attr_ReadOnly = pValue.Attr_ReadOnly;
            Change_DCreate = pValue.Change_DCreate;
            Change_DLastAccess = pValue.Change_DLastAccess;
            Change_DModify = pValue.Change_DModify;
            Change_DCreate_Value = pValue.Change_DCreate_Value;
            Change_DLastAccess_Value = pValue.Change_DLastAccess_Value;
            Change_DModify_Value = pValue.Change_DModify_Value;
            ApplyToSubfolders = pValue.ApplyToSubfolders;
            UnixAttributes = pValue.UnixAttributes;
            UseUnixAttributes = pValue.UseUnixAttributes;
        }

        /// <summary>Aplikovanie obsahu ma zadane hodnoty</summary>
        /// <param name="pAttributes">atributy</param>
        /// <param name="pDCreate">datum vytvorenia</param>
        /// <param name="pDModify">datum zmeny</param>
        /// <param name="pDLastAccess">datum posledneho pristupu</param>
        public void ApplyValues(ref uint pAttributes, ref DateTime pDCreate, ref DateTime pDModify, ref DateTime pDLastAccess)
        {
            pDCreate = Change_DCreate ? Change_DCreate_Value : DateTime.MinValue; // Aplikujem datumy
            pDLastAccess = Change_DLastAccess ? Change_DLastAccess_Value : DateTime.MinValue;
            pDModify = Change_DModify ? Change_DModify_Value : DateTime.MinValue;
            
            if (Attr_Archive != ICore.TS_NONE) // Aplikujem archiv
            {
                if (Attr_Archive == ICore.TS_TRUE) pAttributes |= IWin32.FILE_ATTRIBUTE_ARCHIVE;
                else pAttributes &= ~IWin32.FILE_ATTRIBUTE_ARCHIVE;
            }
            if (Attr_System != ICore.TS_NONE) // Aplikujem system
            {
                if (Attr_System == ICore.TS_TRUE) pAttributes |= IWin32.FILE_ATTRIBUTE_SYSTEM;
                else pAttributes &= ~IWin32.FILE_ATTRIBUTE_SYSTEM;
            }
            if (Attr_Hidden != ICore.TS_NONE) // Aplikujem hidden
            {
                if (Attr_Hidden == ICore.TS_TRUE) pAttributes |= IWin32.FILE_ATTRIBUTE_HIDDEN;
                else pAttributes &= ~IWin32.FILE_ATTRIBUTE_HIDDEN;
            }
            if (Attr_ReadOnly != ICore.TS_NONE) // Aplikujem read only
            {
                if (Attr_ReadOnly == ICore.TS_TRUE) pAttributes |= IWin32.FILE_ATTRIBUTE_READONLY;
                else pAttributes &= ~IWin32.FILE_ATTRIBUTE_READONLY;
            }
        }

        /// <summary>Editacia obsahu pomocou formulara</summary>
        /// <returns>true / false</returns>
        public bool EditWithForm()
        {
            if (UseUnixAttributes)
            {
                using (IFileExplorerForm_ChangeUnixAttributes F = new IFileExplorerForm_ChangeUnixAttributes())
                {
                    F.Value.Assign(this); // Skopirujem obsah
                    bool B = F.ShowDialog() == System.Windows.Forms.DialogResult.OK; // Zobrazim okno
                    if (B) Assign(F.Value); // Skopirujem vysledok
                    return B;
                }
            }
            else
            {
                using (IFileExplorerForm_ChangeAttributes F = new IFileExplorerForm_ChangeAttributes())
                {
                    F.Value.Assign(this); // Skopirujem obsah
                    bool B = F.ShowDialog() == System.Windows.Forms.DialogResult.OK; // Zobrazim okno
                    if (B) Assign(F.Value); // Skopirujem vysledok
                    return B;
                }
            }
        }
    }

    /// <summary>Trieda IFileExplorerForm_ChangeAttributes</summary>
    public class IFileExplorerForm_ChangeAttributes : IForm
    {
        public IAttributeChangeDataObject Value; // Objekt pre editaciu

        protected IGroupBox FGrp; // Controls
        protected IButton FBtn_OK;
        protected IButton FBtn_Cancel;
        protected IButton FBtn_Clear;

        protected IGroupBox FGrp_Attributes;
        protected IComboBox_ThreeState FCombo_Archive;
        protected IComboBox_ThreeState FCombo_Hidden;
        protected IComboBox_ThreeState FCombo_System;
        protected IComboBox_ThreeState FCombo_ReadOnly;
        protected ILabel FLabel_Archive;
        protected ILabel FLabel_Hidden;
        protected ILabel FLabel_System;
        protected ILabel FLabel_ReadOnly;

        protected IGroupBox FGrp_Dates;
        protected IDateTimePicker FDTP_DCreate;
        protected IDateTimePicker FDTP_DModify;
        protected IDateTimePicker FDTP_DLastAccess;
        protected ILabel FLabel_DCreate;
        protected ILabel FLabel_DModify;
        protected ILabel FLabel_DLastAccess;

        protected ICheckBox FCheck_ApplyToSubfolders;

        /// <summary>Konstruktor</summary>
        public IFileExplorerForm_ChangeAttributes()
        {
            Value = new IAttributeChangeDataObject();
        }

        /// <summary>Metoda: OnCreateForm</summary>
        /// <returns>true / false</returns>
        protected override bool OnCreateForm()
        {
            if (!base.OnCreateForm()) return false; // Volam predchodcu

            // Inicializacia
            MinimizeBox = false; MaximizeBox = false; FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; ShowIcon = true; ShowInTaskbar = false; StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

            SetBounds(0, 0, 488, 326); System.Drawing.Size CS = ClientSize;
            Text = lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_5;

            // Vytvorim groupbox
            FGrp = new IGroupBox(); IControl.PlaceControl_Inside(FGrp, this, 10, 10, 10, 50);

            // Vytvorim tlacidla
            FBtn_Clear = new IButton(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_1, Event_BtnClearClick); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FBtn_Clear, FGrp, 0, 10);
            FBtn_Cancel = new IButton(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_3); IControl.PlaceControl_Outside_TopRight_RightBottom(FBtn_Cancel, FGrp, 0, 10); FBtn_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            FBtn_OK = new IButton(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_2, Event_BtnOKClick); IControl.PlaceControl_Outside_TopRight_LeftTop(FBtn_OK, FBtn_Cancel, 0, 10);

            FGrp_Attributes = new IGroupBox(); IControl.PlaceControl_Inside_LeftTop_LeftTop(FGrp_Attributes, this, 10, 10, 170, 300);

            FLabel_Archive = new ILabel(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_4_1);
            FLabel_System = new ILabel(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_4_2);
            FLabel_Hidden = new ILabel(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_4_3);
            FLabel_ReadOnly = new ILabel(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_4_4);
            FCombo_Archive = new IComboBox_ThreeState(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_4_5);
            FCombo_System = new IComboBox_ThreeState(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_4_5);
            FCombo_Hidden = new IComboBox_ThreeState(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_4_5);
            FCombo_ReadOnly = new IComboBox_ThreeState(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_4_5);

            FGrp_Attributes.Controls.AddRange(new System.Windows.Forms.Control[] { FLabel_Archive, FLabel_System, FLabel_Hidden, FLabel_ReadOnly, FCombo_Archive, FCombo_System, FCombo_Hidden, FCombo_ReadOnly });

            IControl.PlaceControl_Inside_LeftTop_LeftTop(FLabel_Archive, FGrp_Attributes, 20, 20);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCombo_Archive, FLabel_Archive, 2, 2);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FLabel_System, FCombo_Archive, -2, 10);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCombo_System, FLabel_System, 2, 2);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FLabel_Hidden, FCombo_System, -2, 10);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCombo_Hidden, FLabel_Hidden, 2, 2);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FLabel_ReadOnly, FCombo_Hidden, -2, 10);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCombo_ReadOnly, FLabel_ReadOnly, 2, 2);
            FGrp_Attributes.Height = FCombo_ReadOnly.Bottom + 20;

            FGrp_Dates = new IGroupBox(); IControl.PlaceControl_Outside_LeftTop_TopRight(FGrp_Dates, FGrp_Attributes, 0, 20, 250, FGrp_Attributes.Height - 50);
            FDTP_DCreate = new IDateTimePicker(true, lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_4_6);
            FDTP_DModify = new IDateTimePicker(true, lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_4_6);
            FDTP_DLastAccess = new IDateTimePicker(true, lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_4_6);
            FLabel_DCreate = new ILabel(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_4_7);
            FLabel_DModify = new ILabel(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_4_8);
            FLabel_DLastAccess = new ILabel(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_4_9);

            FGrp_Dates.Controls.AddRange(new System.Windows.Forms.Control[] { FLabel_DCreate, FLabel_DModify, FLabel_DLastAccess, FDTP_DCreate, FDTP_DModify, FDTP_DLastAccess });

            IControl.PlaceControl_Inside_LeftTop_LeftTop(FLabel_DCreate, FGrp_Dates, 20, 20);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FDTP_DCreate, FLabel_DCreate, 2, 2, 200);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FLabel_DModify, FDTP_DCreate, -2, 10);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FDTP_DModify, FLabel_DModify, 2, 2, 200);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FLabel_DLastAccess, FDTP_DModify, -2, 10);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FDTP_DLastAccess, FLabel_DLastAccess, 2, 2, 200);

            FCheck_ApplyToSubfolders = new ICheckBox(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_4_10);

            FGrp.Controls.AddRange(new System.Windows.Forms.Control[] { FGrp_Attributes, FGrp_Dates, FCheck_ApplyToSubfolders });
            Controls.AddRange(new System.Windows.Forms.Control[] { FGrp, FBtn_OK, FBtn_Cancel, FBtn_Clear }); // Zaradim do controls

            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCheck_ApplyToSubfolders, FGrp_Dates, 10, 20);

            AcceptButton = FBtn_OK; CancelButton = FBtn_Cancel; FBtn_OK.Focus();

            FillForm(Value); // Vyplnim zaciatocnou hodnotou
            return true; // Vsetko OK
        }

        /// <summary>Vyplnenie formulara</summary>
        /// <param name="pValue">hodnota</param>
        protected void FillForm(IAttributeChangeDataObject pValue)
        {
            FCombo_Archive.Value = pValue.Attr_Archive;
            FCombo_System.Value = pValue.Attr_System;
            FCombo_Hidden.Value = pValue.Attr_Hidden;
            FCombo_ReadOnly.Value = pValue.Attr_ReadOnly;
            FDTP_DCreate.Value = pValue.Change_DCreate ? pValue.Change_DCreate_Value : DateTime.MinValue;
            FDTP_DModify.Value = pValue.Change_DModify ? pValue.Change_DModify_Value : DateTime.MinValue;
            FDTP_DLastAccess.Value = pValue.Change_DLastAccess ? pValue.Change_DLastAccess_Value : DateTime.MinValue;
            FCheck_ApplyToSubfolders.Checked = pValue.ApplyToSubfolders;
        }
        /// <summary>Nacitanie obsahu formulara</summary>
        /// <param name="Result">vysledok</param>
        protected void ReadForm(IAttributeChangeDataObject Result)
        {
            Result.ApplyToSubfolders = FCheck_ApplyToSubfolders.Checked;
            Result.Attr_Archive = FCombo_Archive.Value;
            Result.Attr_System = FCombo_System.Value;
            Result.Attr_Hidden = FCombo_Hidden.Value;
            Result.Attr_ReadOnly = FCombo_ReadOnly.Value;
            Result.Change_DCreate_Value = FDTP_DCreate.Value;
            Result.Change_DCreate = FDTP_DCreate.Checked;
            Result.Change_DModify_Value = FDTP_DModify.Value;
            Result.Change_DModify = FDTP_DModify.Checked;
            Result.Change_DLastAccess_Value = FDTP_DLastAccess.Value;
            Result.Change_DLastAccess = FDTP_DLastAccess.Checked;
        }

        /// <summary>Event: OnClick pre tlacidlo FBtn_Clear</summary>
        /// <param name="pSender">zdroj</param>
        /// <param name="e">parameter</param>
        protected void Event_BtnClearClick(object pSender, EventArgs e)
        {
            FillForm(new IAttributeChangeDataObject());
        }
        /// <summary>Event: OnClick pre tlacidlo FBtn_OK</summary>
        /// <param name="pSender">zdroj</param>
        /// <param name="e">parameter</param>
        protected void Event_BtnOKClick(object pSender, EventArgs e)
        {
            ReadForm(Value); // Nacitam obsah
            DialogResult = System.Windows.Forms.DialogResult.OK; // Ukoncim dialog
        }
    }

    /// <summary>Trieda IFileExplorerForm_ChangeUnixAttributes</summary>
    public class IFileExplorerForm_ChangeUnixAttributes : IForm
    {
        public IAttributeChangeDataObject Value; // Hodnota na editaciu

        protected IGroupBox FGrp; // Controls
        protected IButton FBtn_OK;
        protected IButton FBtn_Cancel;

        protected IGroupBox FGrp_Owner;
        protected ICheckBox FCheckRead_Owner;
        protected ICheckBox FCheckWrite_Owner;
        protected ICheckBox FCheckExec_Owner;
        protected ICheckBox FCheckStick_Owner;
        protected IGroupBox FGrp_Group;
        protected ICheckBox FCheckRead_Group;
        protected ICheckBox FCheckWrite_Group;
        protected ICheckBox FCheckExec_Group;
        protected ICheckBox FCheckStick_Group;
        protected IGroupBox FGrp_Others;
        protected ICheckBox FCheckRead_Others;
        protected ICheckBox FCheckWrite_Others;
        protected ICheckBox FCheckExec_Others;
        protected ICheckBox FCheckStick_Others;

        /// <summary>Konstruktor</summary>
        public IFileExplorerForm_ChangeUnixAttributes()
        {
            Value = new IAttributeChangeDataObject();
        }

        /// <summary>Metoda: OnCreateForm</summary>
        /// <returns>true / false</returns>
        protected override bool OnCreateForm()
        {
            if (!base.OnCreateForm()) return false; // Volam predchodcu

            // Inicializacia
            MinimizeBox = false; MaximizeBox = false; FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; ShowIcon = true; ShowInTaskbar = false; StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

            SetBounds(0, 0, 488, 266); System.Drawing.Size CS = ClientSize;
            Text = lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_5;

            // Vytvorim groupbox
            FGrp = new IGroupBox(); IControl.PlaceControl_Inside(FGrp, this, 10, 10, 10, 50);

            // Vytvorim tlacidla
            FBtn_Cancel = new IButton(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_3); IControl.PlaceControl_Outside_TopRight_RightBottom(FBtn_Cancel, FGrp, 0, 10); FBtn_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            FBtn_OK = new IButton(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_2, Event_BtnOKClick); IControl.PlaceControl_Outside_TopRight_LeftTop(FBtn_OK, FBtn_Cancel, 0, 10);

            FGrp_Owner = new IGroupBox(); FGrp_Owner.Text = lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_6_1;  IControl.PlaceControl_Inside_LeftTop_LeftTop(FGrp_Owner, FGrp, 20, 20, 120, 146);
            FCheckRead_Owner = new ICheckBox(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_6_2);
            FCheckWrite_Owner = new ICheckBox(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_6_3);
            FCheckExec_Owner = new ICheckBox(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_6_4);
            FCheckStick_Owner = new ICheckBox(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_6_5);

            FGrp_Owner.Controls.AddRange(new System.Windows.Forms.Control[] { FCheckRead_Owner, FCheckWrite_Owner, FCheckExec_Owner, FCheckStick_Owner });
            IControl.PlaceControl_Inside_LeftTop_LeftTop(FCheckRead_Owner, FGrp_Owner, 16, 26);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCheckWrite_Owner, FCheckRead_Owner, 0, 10);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCheckExec_Owner, FCheckWrite_Owner, 0, 10);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCheckStick_Owner, FCheckExec_Owner, 0, 10);

            FGrp_Group = new IGroupBox(); FGrp_Group.Text = lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_6_6; IControl.PlaceControl_Outside_LeftTop_TopRight(FGrp_Group, FGrp_Owner, 0, 20, 120, 146);
            FCheckRead_Group = new ICheckBox(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_6_2);
            FCheckWrite_Group = new ICheckBox(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_6_3);
            FCheckExec_Group = new ICheckBox(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_6_4);
            FCheckStick_Group = new ICheckBox(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_6_7);

            FGrp_Group.Controls.AddRange(new System.Windows.Forms.Control[] { FCheckRead_Group, FCheckWrite_Group, FCheckExec_Group, FCheckStick_Group });
            IControl.PlaceControl_Inside_LeftTop_LeftTop(FCheckRead_Group, FGrp_Group, 16, 26);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCheckWrite_Group, FCheckRead_Group, 0, 10);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCheckExec_Group, FCheckWrite_Group, 0, 10);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCheckStick_Group, FCheckExec_Group, 0, 10);

            FGrp_Others = new IGroupBox(); FGrp_Others.Text = lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_6_8; IControl.PlaceControl_Outside_LeftTop_TopRight(FGrp_Others, FGrp_Group, 0, 20, 140, 146);
            FCheckRead_Others = new ICheckBox(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_6_2);
            FCheckWrite_Others = new ICheckBox(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_6_3);
            FCheckExec_Others = new ICheckBox(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_6_4);
            FCheckStick_Others = new ICheckBox(lang.FORM_EDIT_CHANGE_ATTRIBUTES_TEXT_6_9);

            FGrp_Others.Controls.AddRange(new System.Windows.Forms.Control[] { FCheckRead_Others, FCheckWrite_Others, FCheckExec_Others, FCheckStick_Others });
            IControl.PlaceControl_Inside_LeftTop_LeftTop(FCheckRead_Others, FGrp_Others, 16, 26);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCheckWrite_Others, FCheckRead_Others, 0, 10);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCheckExec_Others, FCheckWrite_Others, 0, 10);
            IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCheckStick_Others, FCheckExec_Others, 0, 10);

            FGrp.Controls.AddRange(new System.Windows.Forms.Control[] { FGrp_Owner, FGrp_Group, FGrp_Others });
            Controls.AddRange(new System.Windows.Forms.Control[] { FGrp, FBtn_OK, FBtn_Cancel }); // Zaradim do controls

            AcceptButton = FBtn_OK; CancelButton = FBtn_Cancel; FBtn_OK.Focus();

            FillForm(Value); // Vyplnim zaciatocnou hodnotou
            return true; // Vsetko OK
        }

        /// <summary>Vyplnenie formulara</summary>
        /// <param name="pValue">hodnota</param>
        protected void FillForm(IAttributeChangeDataObject pValue)
        {
            bool[] B = ICore.UnixModeToBoolArray(pValue.UnixAttributes); // Prevediem
            FCheckStick_Owner.Checked = B[0]; // Vyplnim 
            FCheckStick_Group.Checked = B[1];
            FCheckStick_Others.Checked = B[2];
            FCheckRead_Owner.Checked = B[3];
            FCheckWrite_Owner.Checked = B[4];
            FCheckExec_Owner.Checked = B[5];
            FCheckRead_Group.Checked = B[6];
            FCheckWrite_Group.Checked = B[7];
            FCheckExec_Group.Checked = B[8];
            FCheckRead_Others.Checked = B[9];
            FCheckWrite_Others.Checked = B[10];
            FCheckExec_Others.Checked = B[11];
        }
        /// <summary>Nacitanie obsahu formulara</summary>
        /// <param name="Result">vysledok</param>
        protected void ReadForm(IAttributeChangeDataObject Result)
        {
            bool[] B = new bool[12];
            B[0] = FCheckStick_Owner.Checked; // Nacitam checkboxy
            B[1] = FCheckStick_Group.Checked;
            B[2] = FCheckStick_Others.Checked;
            B[3] = FCheckRead_Owner.Checked;
            B[4] = FCheckWrite_Owner.Checked;
            B[5] = FCheckExec_Owner.Checked;
            B[6] = FCheckRead_Group.Checked;
            B[7] = FCheckWrite_Group.Checked;
            B[8] = FCheckExec_Group.Checked;
            B[9] = FCheckRead_Others.Checked;
            B[10] = FCheckWrite_Others.Checked;
            B[11] = FCheckExec_Others.Checked;
            Result.UnixAttributes = ICore.BoolArrayToUnixMode(B); // Prevediem
        }

        /// <summary>Event: OnClick pre tlacidlo FBtn_OK</summary>
        /// <param name="pSender">zdroj</param>
        /// <param name="e">parameter</param>
        protected void Event_BtnOKClick(object pSender, EventArgs e)
        {
            ReadForm(Value); // Nacitam obsah
            DialogResult = System.Windows.Forms.DialogResult.OK; // Ukoncim dialog
        }

    }
}
